package net.cyue.homework.student.management.util;

import jakarta.servlet.http.HttpSession;
import net.cyue.nest.nestjava.common.interfaces.http.IHTTPRequest;

public class CodeUtil {

    public static boolean verifyCode(HttpSession session, String inputCode) {
        String code = (String) session.getAttribute("code");
        System.out.println("输入的验证码：" + inputCode);
        if (
    		inputCode == null ||
    		inputCode.isEmpty() ||
    		inputCode.isBlank()
		) {
        	return false;
        }
        return inputCode.equalsIgnoreCase(code);
    }

    public static boolean verifyCode(IHTTPRequest request, String inputCode) {
        HttpSession session = request.getSession();
        return CodeUtil.verifyCode(session, inputCode);
    }
}

